﻿package  {
	
	import com.event.GameEvent;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class levelSelect extends MovieClip {
		
		public var level_1:MovieClip
		public var level_2:MovieClip
		public var level_3:MovieClip
		public var level_4:MovieClip
		public var level_5:MovieClip
		public var level_6:MovieClip
		public var level_7:MovieClip
		public var level_8:MovieClip
		public var level_9:MovieClip
		public var level_10:MovieClip
		public function levelSelect() {
			// constructor code
			for(var i:int = 1;i<=10;i++){
				this["level_"+i].addEventListener(MouseEvent.CLICK,onClick);
			}
		}
		private function onClick(e:MouseEvent):void{
			var evt:GameEvent = new GameEvent(GameEvent.GAME_LEVEL_SELECT);
			evt.level = int((e.target as MovieClip).name.substr(6));
			dispatchEvent(evt);
		}
		public function showLevel(p_level:int):void{
			for(var i:int = 1;i<=10;i++){
				this["level_"+i]
			}
		}
	}
	
}
